//
//  DrawTeachSecVC.m
//  Cat
//
//  Created by dllo on 15/11/30.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "DrawTeachSecVC.h"

@interface DrawTeachSecVC ()

@property (nonatomic, assign) NSInteger ver;

@end

@implementation DrawTeachSecVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createData:[NSString stringWithFormat:@"http://api.huapipi.com/recommend/v2/detail/%@?uid=1033268", self.secid]];
    
    MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshAction)];
    self.tableView.header = header;
    
    MJRefreshAutoGifFooter *footer = [MJRefreshAutoGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(refreshAction)];
    self.tableView.footer = footer;
    self.ver = 0;
}

- (void)refreshAction {
    if ([self.tableView.footer isRefreshing]) {
        self.ver++;
        NSString *URL = [NSString stringWithFormat:@"http://api.huapipi.com/recommend/v2/detail/%@?uid=1033268&ver=%ld", self.secid, self.ver];
        [ToolNetWorking ToolNetWorking:URL block:^(id result) {
            NSMutableArray *tempArr = [TableViewControllerModel BaseModel:result[@"rows"]];
            [self.arr addObjectsFromArray:tempArr];
            [self.tableView reloadData];
        }];
        
        [self.tableView.footer endRefreshing];
    }else {
        self.ver = 0;
        [self createData:[NSString stringWithFormat:@"http://api.huapipi.com/recommend/v2/detail/%@?uid=1033268", self.secid]];
        [self.tableView.header endRefreshing];
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.tabBarController.tabBar.hidden = NO;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
